package com.cyandpos.pad.tradedetails.presenter;


import com.cyandpos.pad.posdata.Order;
import com.cyandpos.pad.posdata.QueryOrderReq;
import com.cyandpos.pad.posdata.RefundOrder;
import com.cyandpos.pad.tradedetails.model.TradeDetailsModel;
import com.cyandpos.pad.tradedetails.model.TradeDetailsModelImpl;
import com.cyandpos.pad.tradedetails.view.TradeDetailsView;

import java.util.List;

/**
 * Created by zhangyp on 2017/3/1.
 */

public class TradeDetailsPresenterImpl implements TradeDetailsPresenter,TradeDetailsModelImpl.OnLoadTradeDetailsListener{
    private TradeDetailsView mTradeDetailsView;
    private TradeDetailsModel mTradeDetailsModel;
    public TradeDetailsPresenterImpl(TradeDetailsView mTradeDetailsView){
        this.mTradeDetailsView = mTradeDetailsView;
        mTradeDetailsModel = new TradeDetailsModelImpl();

    }

    @Override
    public void QueryTradeDetails(QueryOrderReq req) {
        mTradeDetailsView.showProgress();
        mTradeDetailsModel.loadTradeDetailsConfig(req,this);

    }


    @Override
    public void onLoadTradeDetailsSuccess(List<Order> json, double orderCount, RefundOrder data) {
        mTradeDetailsView.hideProgress();
        mTradeDetailsView.onTradeDetailsSuccess(json,orderCount,data);

    }

    @Override
    public void onLoadTradeDetailsFailure(String errorMsg) {
        //model 网络请求失败
        mTradeDetailsView.hideProgress();
        mTradeDetailsView.showLoadFailMsg(errorMsg);

    }
}
